package IO;
import java.io.Reader;
import java.io.FileReader;
import java.io.IOException;

public class IO_Demo10 {
    public static void main(String[] args) {
//        使用字符流读取文件内容
        try(Reader reader = new FileReader("./test2.txt")){
            while(true){
                char[] buffer = new char[1024];
                int n = reader.read(buffer);
                if (n == -1){
                    break;//读取结束
                }
                String s = new String(buffer,0,n);
                System.out.println(s);
            }
        }catch(IOException e){
            throw new RuntimeException(e);
        }
    }
}
